import 'package:flutter/material.dart';

class JueJinDemo extends StatelessWidget {
  JueJinDemo(
      {Key? key,
      required this.title,
      required this.iconData,
      this.info,
      this.notifyInfo})
      : super(key: key);
  final IconData iconData;
  final String title;
  String? info;
  String? notifyInfo;

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 45,
       child: Row(
        children: [
          const SizedBox(width: 30,),
          Icon(
            iconData,
            size: 20,
          ),
          const SizedBox(width: 30,),
          Expanded(
              child: Text(
            title,
            style: const TextStyle(fontSize: 20),
          )),
          (info!=null? createInfoWidget(info!): (notifyInfo != null?NotifyInfo(notifyInfo!):null)),
          // (info != null
          //     ? createInfoWidget(info!)
          //     : (notifyInfo != null ? Text(notifyInfo!) : null)),
          const SizedBox(width: 30,),
        ],
      ),
    );
  }

  createInfoWidget(String info) {
    return Text(
      info,
      style: const TextStyle(fontSize: 20),
    );
  }
}

class CommonInfo extends StatelessWidget {
  const CommonInfo({Key? key, required this.info}) : super(key: key);
  final String info;

  @override
  Widget build(BuildContext context) {
    return Text(
      info,
      style: const TextStyle(fontSize: 20, color: Colors.white70),
    );
  }
}

class NotifyInfo extends StatelessWidget {
  const NotifyInfo(this.info, {Key? key}) : super(key: key);
  final String info;

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 10),
      decoration: const BoxDecoration(
        shape: BoxShape.rectangle,
        borderRadius: BorderRadius.all(Radius.circular(50)),
        color: Colors.red,
      ),
      child: Text(info,style: TextStyle(fontSize: 20,color: Colors.white),),
    );
  }
}
